//
//  CnRequestManager.swift
//  CnPhoto
//
//  Created by MyLifeIsNotLost on 2017/8/7.
//  Copyright © 2017年 MyLifeIsNotLost. All rights reserved.
//

import UIKit
import Photos

class CnRequestManager: NSObject {
    
    
    /// 列表图片展示
    ///
    /// - Parameters:
    ///   - asset: 图片对象
    ///   - completeHandler: 获取图片回调
    class func getImage(_ asset:PHAsset?,completeHandler:@escaping (_ image:UIImage)->()) {
        let manager = PHImageManager.default()
        let RequestOptions = PHImageRequestOptions()
        RequestOptions.isSynchronous = false
        RequestOptions.resizeMode = .fast
        RequestOptions.deliveryMode = .opportunistic
        guard let asset = asset else { return }
        manager.requestImage(for: asset, targetSize: CGSize(width: photoListImgW * UIScreen.main.scale, height: photoListImgW  * UIScreen.main.scale), contentMode: .aspectFill, options: RequestOptions) { (img, _) in
            guard let img = img else{ return }
            completeHandler(img)
        }
    }
}







